﻿// CSetOptDlg.cpp: 实现文件
//

#include "pch.h"
#include "afxdialogex.h"
#include "CSetOptDlg.h"
#include "resource.h"
#include "ProjectAA.h"


// CSetOptDlg 对话框

IMPLEMENT_DYNAMIC(CSetOptDlg, CDialogEx)

CSetOptDlg::CSetOptDlg(CWnd* pParent /*=nullptr*/)
	: CDialogEx(IDD_SET_OPT, pParent)
{

}

CSetOptDlg::~CSetOptDlg()
{
}

void CSetOptDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
}


BEGIN_MESSAGE_MAP(CSetOptDlg, CDialogEx)
	ON_BN_CLICKED(IDC_BUTTON_SAVE, &CSetOptDlg::OnBnClickedButtonSave)
END_MESSAGE_MAP()


// CSetOptDlg 消息处理程序


BOOL CSetOptDlg::OnInitDialog()
{
	CDialogEx::OnInitDialog();

	this->InitUiData();

	return TRUE;  // return TRUE unless you set the focus to a control
	// 异常: OCX 属性页应返回 FALSE
}

void CSetOptDlg::InitUiData()
{
	SetDlgItemInt(IDC_EDIT_PRODUCT_ORG, gSystemMgr.productOrgPos);
	SetDlgItemInt(IDC_EDIT_PRODUCT_WORK, gSystemMgr.productWorkPos);
	SetDlgItemInt(IDC_EDIT_TK_POS, gSystemMgr.tkPos);

	CButton* checkIsTkBackHome = (CButton*)GetDlgItem(IDC_CHECK_TK_BACKHOME);
	checkIsTkBackHome->SetCheck(gSystemMgr.isTkBackHome);

	CButton* checkIgnoreGB = (CButton*)GetDlgItem(IDC_CHECK_IGNORE_GB);
	checkIsTkBackHome->SetCheck(gSystemMgr.ignoreGB);

	CButton* checkIgnoreAllTest = (CButton*)GetDlgItem(IDC_CHECK_IGNORE_ALLTEST);
	checkIgnoreAllTest->SetCheck(gSystemMgr.isIgnoreAllTest);
}


void CSetOptDlg::OnBnClickedButtonSave()
{
	int pos = GetDlgItemInt(IDC_EDIT_PRODUCT_ORG);

	if (pos > -437000)
	{
		int mr = AfxMessageBox(L"待机位设置检测不合理，请检查!,是否继续设置", MB_YESNO);

		if (mr == IDNO)
		{
			return;
		}
	}

	gSystemMgr.productOrgPos = GetDlgItemInt(IDC_EDIT_PRODUCT_ORG);
	gSystemMgr.productWorkPos = GetDlgItemInt(IDC_EDIT_PRODUCT_WORK);
	gSystemMgr.tkPos = GetDlgItemInt(IDC_EDIT_TK_POS);

	CButton* checkIsTkBackHome = (CButton*)GetDlgItem(IDC_CHECK_TK_BACKHOME);
	gSystemMgr.isTkBackHome = checkIsTkBackHome->GetCheck();

	CButton* checkIgnoreGB = (CButton*)GetDlgItem(IDC_CHECK_IGNORE_GB);
	gSystemMgr.ignoreGB = checkIgnoreGB->GetCheck();

	CButton* checkIgnoreAllTest = (CButton*)GetDlgItem(IDC_CHECK_IGNORE_ALLTEST);
	gSystemMgr.isIgnoreAllTest = checkIgnoreAllTest->GetCheck();

	gSystemMgr.configOptParam.SaveValueList();
}
